
private ["_display","_mr1text","_mr2text","_mr1_available","_mr2_available"];

if (x_loop_end) exitWith {};

disableSerialization;

_display = uiNameSpace getVariable "X_TELE_DIALOG";

_mr1text = _display displayCtrl 100105;
_mr2text = _display displayCtrl 100106;

_mr1_available = true;
_mr2_available = true;

_mr1text ctrlSetText "";
_mr2text ctrlSetText "";

if (!isNil "MRR1") then {
	switch (true) do {
		case (["mr1_in_air",False] call XNetGetJIP): {
			_mr1text ctrlSetText "Mobile respawn one gets transported by airlift...";
			_mr1_available = false;
		};
		case (speed MRR1 > 4): {
			_mr1text ctrlSetText "Mobile respawn one currently driving...";
			_mr1_available = false;
		};
		case (surfaceIsWater [(position MRR1) select 0,(position MRR1) select 1]): {
			_mr1text ctrlSetText "Mobile respawn one is currently in water...";
			_mr1_available = false;
		};
		default {
			_depl = [MRR1, "D_MHQ_Deployed", false] call XfGetVar;
			if (!_depl) then {
				_mr1text ctrlSetText "Mobile respawn one not deployed...";
				_mr1_available = false;
			};
		};
	};
} else {
	_mr1_available = false;
};

if (!isNil "MRR2") then {
	switch (true) do {
		case (["mr2_in_air",False] call XNetGetJIP): {
			_mr2text ctrlSetText "Mobile respawn two gets transported by airlift...";
			_mr2_available = false;
		};
		case (speed MRR2 > 4): {
			_mr2text ctrlSetText "Mobile respawn two currently driving...";
			_mr2_available = false;
		};
		case (surfaceIsWater [(position MRR2) select 0,(position MRR2) select 1]): {
			_mr2text ctrlSetText "Mobile respawn two is currently in water...";
			_mr2_available = false;
		};
		default {
			_depl = [MRR2, "D_MHQ_Deployed", false] call XfGetVar;
			if (!_depl) then {
				_mr2text ctrlSetText "Mobile respawn two not deployed...";
				_mr2_available = false;
			};
		};
	};
} else {
	_mr2_available = false;
};

if (x_loop_end) exitWith {};

_lhd = ["LHD_Teleporter_Landing", ObjNull] call XNetGetJIP;
if (isNull _lhd) then {
	_button = _display displayCtrl 100121;
	_button ctrlEnable false;
};

if (!_mr1_available) then {
	_button = _display displayCtrl 100108;
	_button ctrlEnable false;
	if (d_beam_target == 1) then {
		d_beam_target = -1;
		_textctrl = _display displayCtrl 100110;
		_textctrl ctrlSetText "";
	};
} else {
	_button = _display displayCtrl 100108;
	_button ctrlEnable true;
};

if (!_mr2_available) then {
	_button = _display displayCtrl 100109;
	_button ctrlEnable false;
	if (d_beam_target == 2) then {
		d_beam_target = -1;
		_textctrl = _display displayCtrl 100110;
		_textctrl ctrlSetText "";
	};
} else {
	_button = _display displayCtrl 100109;
	_button ctrlEnable true;
};
